<?php
/**
 * reg controller
 * @package app-home_controller_member
 */
load_controller('/homebase');
/**
 * reg controller
 * @author pandajingjing
 * @package app-home_controller_member
 */
class member_regcontroller extends homebasecontroller{

	function doRequest(){
		$arrErrInfo=array();
		$strUserName='';
		$strAction=$this->getParam('action','url');
		if('callback'==$strAction){
			$strStatus=$this->getParam('status','url');
			if('ok'==$strStatus){
				$strToURL=base64_decode($this->getParam('to','url'));
				if(''==$strToURL){
					//@todo 前往默认页
				}else{
					$this->redirectURL($strToURL);
				}
			}elseif('fail'==$strStatus){
				$strUserName=base64_decode($this->getParam('txtUserName','url'));
				$arrErrInfo=json_decode(base64_decode($this->getParam('errmsg','url')),true);
			}
		}
		
		load_lib('/bll/member/home');
		$clsBllMember=new bll_member_home();
		
		load_controller('/home/home');
		
		$strRegURL=$clsBllMember->getMemCenterURL('reg',self::getURL('callback',array( 
				'to'=>base64_encode(home_homecontroller::getURL()) 
		)),$this->getTime(),'api');
		$arrUserInfo=$clsBllMember->decryptLoginInfo($this->getParam('authcode','cookie'));
		
		$this->setData('strRegURL',$strRegURL);
		$this->setData('arrUserInfo',$arrUserInfo);
		
		$this->setViewState('frmReg','txtUserName',$strUserName);
		$this->setViewState('frmReg','hidAction','reg');
		
		$this->setData('arrErrInfo',$arrErrInfo);
		return '/member/reg';
	}

	/**
	 * 获取访问该控制器的路径
	 */
	static function getURL($p_strAction='',$p_arrParam=array(),$p_bolSecure=false,$p_strPre='/member/reg'){
		return parent::getURL('/member/reg',$p_strAction,$p_arrParam);
	}
}